package com.bjdd.jdy.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by Administrator on 2017/4/7.
 */

public class StringUtils {
    public static String SecretKey = "c7b302432e2a16f77ebdf44455585491";
    public static boolean isPhone(String mobiles) {
//        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
//        Matcher m = p.matcher(mobiles);
        if (mobiles.length() != 11){
            return false;
        }
        //return m.matches();
        return true;
    }
    public static boolean isIdCard(String id){
        if (id.length() != 18){
            return false;
        }else {
            return true;
        }
    }
    public static String MD5(String str){
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            str = new BigInteger(1,md.digest()).toString(16);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return str;
    }
}
